<?php
defined ( 'SYSPATH' ) or die ( 'No direct script access.' );

class Controller_Test extends Controller {
//class Controller_Test extends Controller_Template {
	
	public function before() {
		parent::before ();
	}
	
	public function after() {
		
		parent::after ();
	}
	
	public function action_index() {
		set_time_limit(0);
		$conn = MON::connect(get_object_vars(project::config('conndb')));
		$t = lib_unittest::start();
		
		/*$url = 'http://www.php302.com/';
		$r = Model::factory('tool_seo')->get_headers($url);
		var_dump($r);
		exit;*/
		
		$url = 'http://tool.chinaz.com/baidu/words.aspx';
		$o = curl_init($url);
		curl_setopt($o,CURLOPT_RETURNTRANSFER,true);
		//curl_setopt($o,CURLOPT_NOBODY, true);
		curl_setopt($o,CURLOPT_POST,true);
		curl_setopt($o,CURLOPT_POSTFIELDS,array('kw'=>'php'));
		$h = curl_exec($o);
		
		echo $h;
		
		$t->end();
		exit;
	}
	
	public function action_pushtodo() {
		set_time_limit(0);
		$conn = MON::connect(get_object_vars(project::config('conndb')));
		$t = lib_unittest::start();
		
		$mysql = MysqlDB::instance(array(
			'host' => '199.119.205.226',
			//'dbname' => 'phpboke',
			'username' => 'finger',
			'password' => 'nB1297cK+6bqmEV',
			//'table_prefix' => 'tab_'
		));
		$mysql->select_db('51cto');
		$r = MYSQL::factory('content')->select('标题','内容','时间','PageUrl')->exec();
		//var_dump($r);
		
		foreach ($r as $a){
			if (strlen($a['内容']) < 200) continue;
			MON::factory('todo')->insert(array(
				'title'=>$a['标题'],        
			    'rewrite'=>$a['标题'],
			    'keywords'=>'',
			    'description'=>'',
			    'content'=>htmlspecialchars($a['内容']),
				'url'=>$a['PageUrl'],
			    'time'=>strtotime($a['时间']),
				'addTime'=>time()
			));
		}
		
		
		$t->end();
		exit;
	}
	
	public function action_woosau(){
		$conn = MON::connect(get_object_vars(project::config('conndb')));
		Model::factory('tag')->tag_batch();
		
		exit;
	}

    public function action_clear(){
        $m = m::factory('smarty');
        $m->clearAllCache();
    }
} // End Welcome
